#!/usr/bin/python

if __name__ == "__main__":
    from optparse import OptionParser
    from pgdump_rsync.xmlrpc_transport import XMLRPCSyncServer
    from pgdump_rsync.server import SyncServer

    parser = OptionParser(usage="usage: \n  %prog <dump-file>")

    parser.add_option("-p", "--protocol", action="store", type="string",
                      dest="protocol", default="xmlrpc",
                      help="Transport protocol to use. Only xmlrpc available")

    XMLRPCSyncServer.add_parse_opts(parser)

    (opts, args) = parser.parse_args()

    if len(args) != 1:
        parser.error("Error only one argument expected")

    server = SyncServer(args[0])

    if opts.protocol == "xmlrpc":
        x_server = XMLRPCSyncServer(server, opts)
        x_server.serve_forever()
